package us.icitap.utils;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.activation.DataSource;


public class AppDataSource implements DataSource{

	public enum ContentType{
		PDF("application/pdf"),
		EXCEL("application/vnd.ms-excel");
		
		String type;
		
		private ContentType(String type) {
			this.type = type;
		}
		
		public String toString(){
			return this.type;
		}
		
	}
	private String contentType;
	
	private ByteArrayOutputStream outputStream;
	
	private String name;
	public AppDataSource(ContentType contentType, String fileName) {
		this.contentType = contentType.toString();
		this.name = fileName;
	}
	

	public String getContentType() {
		return this.contentType;
	}


	public InputStream getInputStream() throws IOException {
		return  new ByteArrayInputStream(outputStream.toByteArray()); 
	
	}


	public String getName() {
		// TODO Auto-generated method stub
		return name;
	}


	public OutputStream getOutputStream() throws IOException {
		// TODO Auto-generated method stub
		return outputStream;
	}


	public void setOutputStream(ByteArrayOutputStream outputStream) {
		this.outputStream = outputStream;
	}


}
